<template>
<div>
  <div  style="text-align: center; margin-top:250px; font-size: 30px;">
    訂單編號: {{this.$route.query.orderId}}
  </div>

  <div style="width: 100px; margin: auto; margin-top: 60px;">
    <el-button style="width: 100px;" type="success" @click="pay">付款</el-button>
  </div>


</div>

</template>

<script>
export default {
  name: "Pay",
  methods: {
    pay() {
      let orderId = this.$route.query.orderId;
      console.log(orderId);

      this.$http.get("/order/pay/" + orderId).then((response) => {

        let result = response.data
        let status = result.status
        console.log(status)

        if (status == -1) {
          this.$message.error("該訂單已過期!!");

          setTimeout(() => {
            this.$router.push("/list")
          }, 1000);

        } else if (status == 1) {
          this.$message.success("訂單付款成功")

          setTimeout(() => {
            this.$router.push("/success")
          }, 1000);
        }




      });

    }
  },
  created() {
    console.dir(this.$route)
  }
}
</script>

<style scoped>

</style>
